package com.zzx.es.mapper;

import com.zzx.es.entity.Product;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.elasticsearch.repository.ElasticsearchRepository;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public interface ProductMapper extends ElasticsearchRepository<Product, Long> {

    // 此处使用SpringData格式方法进行查询，无需手写实现

    // 根据category查询并根据id进行排序
    List<Product> findByCategoryOrderById(String category);

    // 根据category查询并分页
    Page<Product> findByCategoryOrderById(String category, Pageable pageable);

    // 根据category查询总数
    Integer countByCategory(String category);

}